package cn.shenlong.front.action;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 *  
 * @author zhengjinfeng
 *
 */
@Controller
public class CommonPage {
	private static final Logger log = LoggerFactory.getLogger(CommonPage.class);

	@RequestMapping(value = "/front/header-", method = RequestMethod.GET)
	public String header(HttpServletRequest request, ModelMap model) {
		return "/front/header";
	}

	@RequestMapping(value = "/front/footer-", method = RequestMethod.GET)
	public String footer(HttpServletRequest request, ModelMap model) {
		return "/front/footer";
	}
	
	
	@RequestMapping(value = "/front/topBar", method = RequestMethod.GET)
	public String topBar(HttpServletRequest request, ModelMap model) {
		return "/front/topBar";
	}
	
	/**
	 * 用户 活动 预览
	 * @param title
	 * @param conentImg
	 * @param html
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/front/eventShow")
	public String eventShow(String title,String conentImg,String html,HttpServletRequest request, ModelMap model ) {
		if(!StringUtils.isBlank(title)){
			model.addAttribute("title", title);
		}
		if(!StringUtils.isBlank(conentImg)){
			model.addAttribute("conentImg", conentImg);
		}
		
		if(!StringUtils.isBlank(html)){
			try {
				model.addAttribute("html", URLDecoder.decode(html,"UTF-8"));
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
  
		return "/front/eventShow";
	}
	
}
